<?xml version="1.0" encoding="UTF-8"?>
<!-- 
 Copyright (C) 2014 - Open Source Geospatial Foundation. All rights reserved.
 This code is licensed under the GPL 2.0 license, available at the root
 application directory.
 -->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">

  <!-- The repository managing the transformations -->
  <bean id="transformRepository" class="org.geoserver.wfs.xslt.config.TransformRepository">
    <constructor-arg index="0" ref="dataDirectory" />
    <constructor-arg index="1" ref="catalog" />
  </bean>

  <!-- The output format -->
  <bean id="xsltOutputFormat" class="org.geoserver.wfs.xslt.XSLTOutputFormat">
    <constructor-arg index="0" ref="geoServer" />
    <constructor-arg index="1" ref="transformRepository" />
  </bean>

  <!-- The task updating the set of output formats -->
  <bean id="xsltOutputFormatUpdater" class="org.geoserver.wfs.xslt.XSLTOutputFormatUpdater">
    <constructor-arg ref="transformRepository" />
  </bean>

  <!-- Definition of how often the scheduled task runs -->
  <bean id="xlstOutputFormatsTask"
    class="org.springframework.scheduling.concurrent.ScheduledExecutorTask">
    <!-- run every second -->
    <property name="period" value="1000" />
    <property name="runnable" ref="xsltOutputFormatUpdater" />
  </bean>

  <!-- And finally the class that instantiates the scheduled tasks and makes 
    them run -->
  <bean id="xsltTimerFactory" class="org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean"
    lazy-init="false">
    <property name="scheduledExecutorTasks">
      <list>
        <ref bean="xlstOutputFormatsTask" />
      </list>
    </property>
    <property name="daemon" value="true" />
  </bean>

  <context:component-scan base-package="org.geoserver.wfs.xslt.rest"/>

  <bean id="xsltExtension"
		class="org.geoserver.platform.ModuleStatusImpl">
		<property name="module" value="gs-xslt" />
		<property name="name" value="XLST based WFS output format" />
		<property name="component" value="XLST based WFS output format extension" />
		<property name="available" value="true" />
		<property name="enabled" value="true" />
  </bean>
</beans>
